from django.contrib import admin
from rotiadm.app.models import *

class ResourceAdmin(admin.ModelAdmin):
    date_hierarchy = 'last_updated'
    exclude = ('version',)
    list_display = ('title', 'url', 'feed_url', 'last_updated')
    list_filter = ('last_updated',)
    search_fields = ('title', 'url', 'feed_url')

class EntryAdmin(admin.ModelAdmin):
    date_hierarchy = 'published_date'
    exclude = ('version',)
    list_display = ('title', 'link')
    list_filter = ('published_date', 'last_updated')
    search_fields = ('title', 'link')
    raw_id_fields = ('resource',)
    
class AccountAdmin(admin.ModelAdmin):
    exclude = ('version',)
    list_display = ('code',)
    search_fields = ('code',)
    
class SearchControlListAdmin(admin.ModelAdmin):
    exclude = ('version',)
    list_display = ('account', 'resource', 'filter_flag')
    search_fields = ('account__code', 'resource__url', 'resource__title')
    raw_id_fields = ('resource',)

admin.site.register(Resource, ResourceAdmin)
admin.site.register(Account, AccountAdmin)
admin.site.register(Entry, EntryAdmin)
admin.site.register(SearchControlList, SearchControlListAdmin)